package test;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;

import server.Request;
import server.Response;
import entity.User;

public class ServerDemo {
	public static void main(String[] args) throws Exception {
		ServerSocket serverSocket=new ServerSocket(9091);
		Socket socket=serverSocket.accept();
		ObjectOutputStream out=new ObjectOutputStream(socket.getOutputStream());
		ObjectInputStream in=new ObjectInputStream(socket.getInputStream());
		Request request=(Request)in.readObject();
		Object[] params=(Object[])request.getArgs();
		System.out.println("param:"+params[0]+","+params[1]);
		User user=null;
		if (params[0].equals(1001)&&params[1].equals("1234")) {
			user=new User(1001,"刘苍松","1234");
		}
		System.out.println(user);
		UUID uuid=UUID.randomUUID();
		Response response=new Response(uuid.toString(),user);
		out.writeObject(response);
		out.flush();
		socket.close();
	}
}
